
<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 control-label">
        <span style='color:red'></span>所在区域：</label>
    <div class="col-sm-8 col-xs-8">
              <div class="input-group form-group">
         
                {if $citys}    
                <span style="display:table-cell; "> 
 {php echo form_element::select($citys,'data[city_id]','city_id',$item['city_id'],'1','city', 'onchange="navcityto(this)"');}
</span>
{/if} 
         <span id="areasbd" style="display:table-cell; ">         
 {php echo  form_element::select($sec['areas'],'data[area]','area',$item['area']);}
     </span>
          <span style="display:table-cell; "> 商圈： </span>
        <span style="display:table-cell; "> 
            <select name="data[quan]" id="quan">
                             {if $item['quan']}
                             <option value="{$item['quan']}">{$item['quan']}</option>
                             {else}
                             <option value="">-请选择商圈-</option>
                             {/if}
                         </select> 
        </span>
        <span style="display:table-cell; "> 
        <a class="btn btn-default"  data-toggle="modal" data-target="#owner-modal">新增商圈</a>
           </span>   
              </div>   
    </div>
</div> 

  <script type="text/javascript">
     function isnull(str) {
        if ((!str) || (typeof (str) == "undefined") || (str == null) || (str == 0)) {
            return true;
        } else {
            return false;
        }
    };
    /*区域商圈格式数据*/
  
    var areas = {php echo json_encode($selects['quan']) };
    

        /*区域商圈格式数据*/
        function init_area_quan(area) {
            var house_quan = "{$item['quan']}";
            var curr = area;
            if (isnull(areas[curr])) {
                $("#quan").html('<option value="">-请选择商圈-</option>');
                return;
            }
            var quan = areas[curr];
            var html = "";
            for (var q in quan) {
                var s = quan[q] == house_quan ? 'selected' : '';
                html += '<option ' + s + ' value="' + quan[q] + '">' + quan[q] + '</option>';
            }
            $("#quan").html(html);
        }
        $(function () {
            window.optionchanged = false;
            $('#myTab a').click(function (e) {
                e.preventDefault();//阻止a链接的跳转行为
                $(this).tab('show');//显示当前选中的链接及关联的content
            })
            /*绑定area 的change事件*/
            init_area_quan('{$item['area']}');
            $("#area").change(function () {
                init_area_quan(this.value);

            })
        });
        function navcityto(obj) {
            var id = obj.value;
            $.ajax({
                url: "{php echo $this->createWebUrl('send', array('op'=>'cityareas'))}" + "&id=" + id,
                success: function (ret) {
                    $("#areasbd").html(ret);
                    $("#area").change(function () {
                        init_area_quan(this.value);

                    })
                }
            });

        }
  </script>